<extend name="Public:common"/>
<block name="css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css"  media="all">
    <style>
        .newMess th{text-align:center;}
        th,td{padding: 10px;}
    </style>
</block>
<block name="content">
    <div class="page-header"><h1><i class="fa fa-home"></i> 首页>商家管理>交通供应商>线路审核</h1></div>
     <div class="container-fluid">
         <form action="" method="post">
             <input type="hidden" value="{:I('traffic_priceId')}" name="traffic_priceId">
             <input type="hidden" value="{:I('supplier_id')}" name="supplier_id">
         <table class="table table-striped table-bordered table-hover table-condensed text-center">
             <tbody>

             <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>交通方式</b></td>
                 <td class="text-left">
                     {$trafficInfo.traffic_name}
                 </td>
             </tr>
             <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>座席</b></td>
                 <td class="text-left">
                     {$trafficInfo.seat_name}
                 </td>
             </tr>
             <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>线路名称</b></td>
                 <td class="text-left">
                     <input type="text" name="routes_name" value="{$trafficInfo.routes_name}" required>
                 </td>
             </tr>

             <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>币种</b></td>
                 <td class="text-left">

                     <input type="text" name="money_type"  value="{$trafficInfo.money_type}" readonly>
                 </td>
             </tr>

             <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>出发城市</b></td>
                 <td class="text-left">
                     国家
                     <select name="start_country" id="ar_country_id"  onchange="getProvince(this,'ar')" required>
                         <option value="">==选择国家==</option>
                         <volist name="country" id="vo">
                             <option <if condition="$trafficInfo['start_country'] eq $vo['areaId']">selected</if>  value="{$vo.areaId}">{$vo.areaName}</option>
                         </volist>
                     </select>
                     省
                     <select name="start_province" id="ar_province_id"  onchange="getCity(this,'ar')" required>
                         <option value="">==选择省==</option>
                         <volist name="cityList['start_province_list']" id="vo">
                             <option  <if condition="$trafficInfo['start_province'] eq $vo['areaId']">selected</if>  value="{$vo.areaId}">{$vo.areaName}</option>
                         </volist>
                     </select>
                     市
                     <select name="start_city" id="ar_city_id"  onchange="getArea(this,'ar')" required>
                         <option value="">==选择市==</option>
                         <volist name="cityList['start_city_list']" id="vo">
                             <option  <if condition="$trafficInfo['start_city'] eq $vo['areaId']">selected</if> value="{$vo.areaId}">{$vo.areaName}</option>
                         </volist>
                     </select>
                     区
                     <select name="start_area"   id="ar_area_id"  required>
                         <option value="">==选择区==</option>
                         <volist name="cityList['start_area_list']" id="vo">
                             <option <if condition="$trafficInfo['start_area'] eq $vo['areaId']">selected</if>   value="{$vo.areaId}">{$vo.areaName}</option>
                         </volist>
                     </select>
                 </td>
             </tr>



            <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>目的城市</b></td>
                 <td class="text-left">
                     国家
                     <select name="goal_country" id="goal_country_id"  onchange="getProvince(this,'goal')" required>
                         <option value="">==选择国家==</option>
                         <volist name="country" id="vo">
                             <option <if condition="$trafficInfo['goal_country'] eq $vo['areaId']">selected</if>    value="{$vo.areaId}">{$vo.areaName}</option>
                         </volist>
                     </select>
                     省
                     <select name="goal_province" id="goal_province_id"  onchange="getCity(this,'goal')" required>
                         <option value="">==选择省==</option>
                         <volist name="cityList['goal_province_list']" id="vo">
                             <option  <if condition="$trafficInfo['goal_province'] eq $vo['areaId']">selected</if>  value="{$vo.areaId}">{$vo.areaName}</option>
                         </volist>
                     </select>
                     市
                     <select name="goal_city" id="goal_city_id"  onchange="getArea(this,'goal')" required>
                         <option value="">==选择市==</option>
                         <volist name="cityList['goal_city_list']" id="vo">
                             <option  <if condition="$trafficInfo['goal_city'] eq $vo['areaId']">selected</if>  value="{$vo.areaId}">{$vo.areaName}</option>
                         </volist>
                     </select>
                     区
                     <select name="goal_area"   id="goal_area_id" required >
                         <option value="">==选择区==</option>
                         <volist name="cityList['goal_area_list']" id="vo">
                             <option   <if condition="$trafficInfo['goal_area'] eq $vo['areaId']">selected</if>    value="{$vo.areaId}">{$vo.areaName}</option>
                         </volist>
                     </select>
                 </td>
             </tr>
             <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>成人成本价</b></td>
                 <td class="text-left">
                     <input type="text" name="adult_actual_cost" onkeyup="num(this)" value="{$trafficInfo.adult_actual_cost}" required>
                     {$trafficInfo.money_type}
                 </td>
             </tr>
             <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>儿童成本价</b></td>
                 <td class="text-left">
                     <input type="text" name="child_actual_cost" onkeyup="num(this)" value="{$trafficInfo.child_actual_cost}" required>
                     {$trafficInfo.money_type}
                 </td>
             </tr>
             <tr>
                 <td style="width:25%;"><b> <span class="required">*</span>座位数</b></td>
                 <td class="text-left">
                     <input type="text" name="seat_num" onkeyup="num(this)" value="{$trafficInfo.seat_num}" required>
                 </td>
             </tr>
             <tr>
                 <td colspan="2">
                     <input type="hidden" name="is_review" value="-1">
                     <a class="btn btn-info" href="{:U('trafficProductById',array('id'=>I('supplier_id')))}">返回</a>
                     <button class="btn btn-warning" onclick="pass(-2)" >拒绝</button>
                     <button class="btn btn-primary" onclick="pass(1)" >通过</button>
                 </td>
             </tr>
             </tbody>
         </table>
         </form>
     </div>
</block>
<block name="js">
    <script>


        function pass(is_review) {
            $('input[name="is_review"]').val(is_review);
            $('form').submit();
        }


        //根据汇率自动转换价格
        var foreign=['child_foreign_cost','adult_foreign_cost'];
        var actual=['child_actual_cost','adult_actual_cost'];
        var _foreign,_actual;
        $('body').on('change','.related',function () {
            var name=$(this).attr('name');
            var val=$(this).val();
            var multiply_divide=1;//乘除

            if(name.indexOf('foreign')==-1){
                _foreign=actual;
                _actual=foreign;
                multiply_divide=0;
            }else{
                _foreign=foreign;
                _actual=actual;
                multiply_divide=1;
            }
            for(var i in _foreign){
                //汇率
                var exchangeName=name.replace(_foreign[i],'exchange_rate');
                var exchange_rate=  $('input[name=\''+exchangeName+'\']').val();
                if(!isNaN(exchange_rate)){
                    if(name.indexOf(_foreign[i])!=-1){
                        var changeName=name.replace(_foreign[i],_actual[i]);
                        var result=(val*exchange_rate).toFixed(2);
                        if(multiply_divide){
                            result=(val/exchange_rate).toFixed(2);
                        }
                        $('input[name=\''+changeName+'\']').val(result);
                    }
                }
            }
        });

        //改变汇率更换值
        $('body').on('change','.exchange_rate',function () {
            var reateName=$(this).attr('name');
            var val=$(this).val();
            for(var i in foreign){
                var name=reateName.replace('exchange_rate',foreign[i]);
                var tempVal=$('input[name=\''+name+'\']').val();
                if(tempVal){
                    var actualName=reateName.replace('exchange_rate',actual[i]);
                    var result=(tempVal/val).toFixed(2);
                    $('input[name=\''+actualName+'\']').val(result);
                }else{
                    var name=reateName.replace('exchange_rate',actual[i]);
                    var tempVal=$('input[name=\''+name+'\']').val();
                    if(tempVal){
                        var result=(tempVal*val).toFixed(2);
                        var foreignName=reateName.replace('exchange_rate',foreign[i]);
                        $('input[name=\''+foreignName+'\']').val(result);
                    }
                }
            }
        });



        //限制只能输入2位小数
        function num(obj)
        {
            //先把非数字的都替换掉，除了数字和.
            obj.value = obj.value.replace(/[^\d.]/g,"");
            //必须保证第一个为数字而不是.
            obj.value = obj.value.replace(/^\./g,"");
            //保证只有出现一个.而没有多个.
            obj.value = obj.value.replace(/\.{2,}/g,".");
            //保证.只出现一次，而不能出现两次以上
            obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
            obj.value=obj.value.substring(0,5);
        }

    </script>
</block>